#!/bin/bash
#
# jfindchat           JFind Chat daemon
#
# Author:       X.D Yang <xd.yang@nf-3.com>
#
# chkconfig:	345 97 03
#
# description:  This is a daemon which periodically checks for updates \
#               and can send notifications via mail, dbus or syslog.
# processname:  jfindchat



# source function library
. /etc/rc.d/init.d/functions
EBIN=$HOME/Documents/Erlang/Daemon
ERL=/usr/local/lib/erlang/bin/erl
RETVAL=0
export HOME=/usr/local/JFindMe
start() {
	echo -n $"Starting JFindChat: "
	$ERL -detached -pa /usr/local/JFindMe/ebin -run mainEntry start start
	#daemon +19 'yum-updatesd &'
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/yum-updatesd
}

stop() {
	echo -n $"Stopping JFindChat: "
	killproc yum-updatesd
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/yum-updatesd
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop) 
	stop
	;;
  restart|force-reload|reload)
	restart
	;;
  condrestart|try-restart)
	[ -f /var/lock/subsys/yum-updatesd ] && restart
	;;
  status)
	status yum-updatesd
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
	exit 1
esac

exit $RETVAL
